package dk.pun.aot.shared.character;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.annotations.Embedded;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@SuppressWarnings("serial")
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class CharacterData implements Serializable {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long key;
	@Persistent
	private Date createdDate;
	@Persistent
	private String name;
	@Persistent @Embedded
	private CharacterQualities qualities;
	@Persistent @Embedded
	private CharacterSkills skills;
	
	public CharacterData () {
		this.createdDate = new Date();
		this.qualities = new CharacterQualities ();
		this.skills = new CharacterSkills ();
	}

	public Long getKey() {
		return this.key;
	}

	public Date getCreatedDate() {
		return this.createdDate;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public CharacterQualities getQualities() {
		return this.qualities;
	}

	public void setQualities(CharacterQualities qualities) {
		this.qualities = qualities;
	}
	
	public CharacterSkills getSkills() {
		return this.skills;
	}

	public void setSkills(CharacterSkills skills) {
		this.skills = skills;
	}

	public void copyContent(CharacterData other) {
		other.setName(this.getName());
		other.setQualities(this.getQualities());
		other.setSkills(this.getSkills());
	}

	@Override
	public String toString() {
		return "CharacterData [key=" + key + ", name=" + name + ", strength=" + qualities.getQualityScore(QualityType.STRENGTH) + "]";
	}

}
